<template>
    <ScaleView ref="largeDataScreenRef" :width="1920" :height="1080" class="absolute top-0 left-0 right-0 bottom-0">
        <div class="largeDataScreenId flex-direction-column">
            <div class="header">
                <div class="header-text">
                    <div class="time">
                        <p class="line-height1">{{ data.topDateTime }}</p>
                        <svg-icon class="headerTimeIcon1" icon-class="left_1_svg" />
                        <svg-icon class="headerTimeIcon2" icon-class="left_2_svg" />
                        <svg-icon class="headerTimeIcon3" icon-class="right_1_svg" />
                        <svg-icon class="headerTimeIcon4" icon-class="right_2_svg" />
                    </div>
                    <div>
                        <div class="name">
                            <span class="el-dropdown-link cursorPointer" @click="showProjectFn">{{ data.projectName }}<i
                                   class="el-icon-arrow-down el-icon--right"></i></span>
                            <svg-icon class="headerNameIcon1" icon-class="left_1_svg" />
                            <svg-icon class="headerNameIcon2" icon-class="left_2_svg" />
                            <svg-icon class="headerNameIcon3" icon-class="right_1_svg" />
                            <svg-icon class="headerNameIcon4" icon-class="right_2_svg" />
                        </div>
                        <div class="header-new-drop" @mouseleave="mouseLeave" v-if="data.showProject">
                            <div class="cursorPointer" v-for="item in data.projectList" @click="clickVillageMenu(item)"
                                 :key="item.villageId">{{ item.villageName }}</div>
                        </div>
                        <span @click="full">
                            <svg-icon class="full_screen_svc cursorPointer" icon-class="full_screen_svc" />
                        </span>
                    </div>
                </div>
            </div>
            <div class="content" v-if="data.reloadSwitch">
                <!-- 一列-->
                <div class="contentList">
                    <div class="item item1">
                        <!--基础数据-->
                        <LeftBasicData></LeftBasicData>
                    </div>
                    <div class="item item2">
                        <!--线上用户活跃度-->
                        <LeftOnlineUserActivity></LeftOnlineUserActivity>
                    </div>
                    <div class="item item3">
                        <!--设备情况-->
                        <LeftEquipmentCondition></LeftEquipmentCondition>
                    </div>
                </div>
                <!-- 二列-->
                <div class="contentList">
                    <div class="item item4">
                        <!--线上收缴总数-->
                        <CenterTotalOnlinePayment></CenterTotalOnlinePayment>
                    </div>
                    <div class="item item5">
                        <!--商城流水总数-->
                        <CenterTotalFlowMall></CenterTotalFlowMall>
                    </div>
                    <div class="item item6" style="height: 22%;">
                        <!--当日巡检完成率-->
                        <CenterDaysPatrolInspection></CenterDaysPatrolInspection>
                    </div>
                </div>
                <!-- 三列-->
                <div class="contentList">
                    <div class="item item7">
                        <!--人流量-->
                        <RightVisitorsFlowRate></RightVisitorsFlowRate>
                    </div>
                    <div class="item item8">
                        <!--不同通行方式人员占比-->
                        <RightProportionPersonnel></RightProportionPersonnel>
                    </div>
                    <div class="item item9">
                        <!--停车数据-->
                        <RightParkingData></RightParkingData>
                    </div>
                </div>
            </div>
            <div class="bottom"></div>
        </div>
    </ScaleView>

</template>
<script lang="ts">
export default defineComponent({ name: 'dashboard' })
</script>
<script setup lang="ts">
import ScaleView from '../shared/ScaleView.vue';
import moment from 'moment';
import LeftBasicData from './components/LeftBasicData.vue';
import LeftOnlineUserActivity from './components/LeftOnlineUserActivity.vue';
import LeftEquipmentCondition from './components/LeftEquipmentCondition.vue';
import CenterTotalFlowMall from './components/CenterTotalFlowMall.vue';
import CenterTotalOnlinePayment from './components/CenterTotalOnlinePayment.vue';
import CenterDaysPatrolInspection from './components/CenterDaysPatrolInspection.vue';
import RightVisitorsFlowRate from './components/RightVisitorsFlowRate.vue';
import RightProportionPersonnel from './components/RightProportionPersonnel.vue';
import RightParkingData from './components/RightParkingData.vue';
import { projectList } from "src/api/largeDataScreen";
import { onMounted, onUnmounted, reactive, nextTick, ref, provide, computed, defineComponent } from 'vue';

const data = reactive({
    topDateTime: moment(new Date()).format("YYYY-MM-DD HH:mm"),
    timer: 0,

    projectList: [],
    showProject: false,
    projectName: "",

    villageId: '',
    reloadSwitch: true
})

provide('villageId',computed(() => data.villageId))

const largeDataScreenRef = ref<InstanceType<typeof ScaleView>>()

onMounted(() => {
    data.timer = setInterval(() => {
        data.topDateTime = moment(new Date()).format("YYYY-MM-DD HH:mm");
    }, 1000);
    getProjectList()
})
onUnmounted(() => {
    clearInterval(data.timer)
})

function getProjectList() {
    projectList({ page: 1, pageSize: 1000 }).then(response => {
        if (response.code == 20000) {
            data.projectName = response.data.records[0].villageName;
            data.villageId = response.data.records[0].villageId;
            data.projectList = response.data.records;
            reload()
        }
    })
}
function clickVillageMenu(command) {
    data.projectName = command.villageName;
    data.villageId = command.villageId;
    data.showProject = false
    reload()
    console.log('外面id-->', data.villageId)
}
function mouseLeave() {
    data.showProject = false
}
function showProjectFn() {
    if (data.projectName) {
        data.showProject = !data.showProject
    }
}
function full() {
    let dom = largeDataScreenRef.value?.$el
    if (!document.fullscreenElement) {
        // 全屏
        dom?.requestFullscreen();
    } else {
        // 退出全屏
        if (document.exitFullscreen) {
            document.exitFullscreen();
        }
    }
}
function reload() {
    data.reloadSwitch = false
    nextTick(() => data.reloadSwitch = true)
}
</script>

<style scoped>
.scale-view {
    background: linear-gradient(180deg, #191919 0%, #292928 100%) top/100% 98px no-repeat;
    background-color: #292928;
}

.largeDataScreenId {
    display: flex;
    width: 100%;
    height: 100%;
    background: #292928;
}

.header {
    height: 10%;
    position: relative;
    background: url("./assets/top_navigation_img.png") left/100% no-repeat;
}

.header-text {
    position: absolute;
    height: 58%;
    left: 0;
    right: 0;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
}

.time {
    font-family: 'PingFang SC';
    font-style: normal;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1;
    color: #FFC659;
    vertical-align: middle;
    position: relative;
}

.headerTimeIcon1 {
    font-size: 0.3rem;
    position: absolute;
    left: -0.5rem;
    top: -0.4rem;
}

.headerTimeIcon2 {
    font-size: 0.3rem;
    position: absolute;
    left: -0.5rem;
    bottom: -0.4rem;
}

.headerTimeIcon3 {
    font-size: 0.3rem;
    position: absolute;
    right: -0.5rem;
    top: -0.4rem;
}

.headerTimeIcon4 {
    font-size: 0.3rem;
    position: absolute;
    right: -0.5rem;
    bottom: -0.4rem;
}

.name {
    font-family: 'PingFang SC';
    font-style: normal;
    font-weight: 400;
    font-size: 1rem;
    color: #FFC659;
    display: inline-block;
    vertical-align: middle;
    position: relative;
}

.nameSize {
    font-size: 1rem
}

.nameIcon {
    font-size: 0.5rem;
    margin-left: 1rem;
}

.headerNameIcon1 {
    font-size: 0.3rem;
    position: absolute;
    left: -1.5rem;
    top: -0.15rem;
}

.headerNameIcon2 {
    font-size: 0.3rem;
    position: absolute;
    left: -1.5rem;
    bottom: -0.15rem;
}

.headerNameIcon3 {
    font-size: 0.3rem;
    position: absolute;
    right: -1.5rem;
    top: -0.15rem;
}

.headerNameIcon4 {
    font-size: 0.3rem;
    position: absolute;
    right: -1.5rem;
    bottom: -0.15rem;
}

.full_screen_svc {
    font-size: 2.4rem;
    vertical-align: middle;
    margin-left: 1.8rem;
}

.content {
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    background: #292928 url("./assets/all_around_border.png") center bottom/100% 108% no-repeat;
}

.contentList {
    display: flex;
    flex-direction: column;
    height: calc(100% - 2rem);
    width: 32.5%;
}

.contentList:nth-child(1) {
    padding: 1.5rem 2.2rem 0 2.2rem;
}

.contentList:nth-child(2) {
    padding: 2rem 0 3rem 0;
    width: 35%;
}

.contentList:nth-child(3) {
    padding: 1.5rem 2.2rem 0 2.2rem;
}

.item {
    box-sizing: content-box;
}

.item1 {
    height: 36.5%;
}

.item2 {
    height: 34%;
}

.item3 {
    height: 29.5%;
}

.item4 {
    height: 38%;
}

.item5 {
    height: 40%;
}

.item6 {
    height: 22%;
}

.item7 {
    height: 35.5%;
}

.item8 {
    height: 26%;
}

.item9 {
    height: 38.5%;
}

.bottom {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2rem;
    background: url("./assets/bottom_navigation_img.png") center bottom/100% 100% no-repeat;
}

:deep .el-dropdown-link {
    color: #FFC659;
}



:deep .el-dropdown-menu__item {
    height: 2rem;
    padding: 0 1rem;
    line-height: 2rem;
    color: #FFC659;
    background: #292928;
}
</style>

<style scoped>
.header-new-drop {
    background: #292928;
    max-height: 30rem;
    border: 1px solid #FFC659 !important;
    overflow: auto;
    position: absolute;
    right: 50px;
    top: 3.5rem;
    padding: 1rem 0;
    border-radius: 0.5rem;
    z-index: 9;
}

.header-new-drop div {
    height: 2rem;
    padding: 0 1rem;
    line-height: 2rem;
    min-width: 5rem;
    color: #FFC659
}

.header-new-drop div:hover,
.div:focus {
    background-color: #292928;
    color: #FFC659;
    font-weight: bold;
}

.header-new-drop .popper__arrow:after {
    border-bottom-color: #FFC659 !important;
    display: none;
}
</style>